﻿CREATE VIEW [dbo].[VMonthlyAccountantReport]
AS
SELECT     dbo.Board.BoardNumber, dbo.CustomerLoans.LoanNumber, dbo.LoanExecutionInstallments.OriginalInstallmentAmount, 
                      dbo.LoanExecutionInstallments.InterestInstallmentAmount, dbo.LoanExecutionInstallments.TotalInstallmentAmount, dbo.LoanExecutionInstallments.PenaltyAmount, 
                      dbo.LoanInstallmentPayments.PaymentAmount, dbo.LoanInstallmentPayments.PaymentDate, dbo.Receipts.ReceiptNumber, dbo.Receipts.ReceiptDate, 
                      dbo.Users.Username, dbo.CommitteeBankAccountDeposites.DepositDate, dbo.CommitteeBankAccountDeposites.OperationNumber, 
                      dbo.LoanExecutionInstallments.InstallmentDate
FROM         dbo.Users INNER JOIN
                      dbo.LoanExecutionInstallments INNER JOIN
                      dbo.LoanInstallmentPayments ON 
                      dbo.LoanExecutionInstallments.LoanExecutionInstallmentID = dbo.LoanInstallmentPayments.LoanExecutionInstallmentID INNER JOIN
                      dbo.LoanExecution ON dbo.LoanExecutionInstallments.LoanExecutionID = dbo.LoanExecution.LoanExecutionID INNER JOIN
                      dbo.CustomerLoans INNER JOIN
                      dbo.BoardLoans ON dbo.CustomerLoans.LoanID = dbo.BoardLoans.LoanID INNER JOIN
                      dbo.Board ON dbo.BoardLoans.BoardID = dbo.Board.BoardID ON dbo.LoanExecution.LoanID = dbo.CustomerLoans.LoanID INNER JOIN
                      dbo.Receipts ON dbo.LoanInstallmentPayments.ReceiptID = dbo.Receipts.ReceiptID ON dbo.Users.UserID = dbo.CustomerLoans.ResponsibleID INNER JOIN
                      dbo.CommitteeBankAccountDepositReceipts ON dbo.Receipts.ReceiptID = dbo.CommitteeBankAccountDepositReceipts.ReceiptID INNER JOIN
                      dbo.CommitteeBankAccountDeposites ON 
                      dbo.CommitteeBankAccountDepositReceipts.CommitteeBankAccountDepositID = dbo.CommitteeBankAccountDeposites.CommitteeBankAccountDepositID
